const app = getApp()
Page({
  data: {
    hasUserInfo: false,
    loadingHidden: false,//代表出现加载
    recorddata:{}
  },
  //获取数据列表
  getLocation: function (options) {
    var that = this;
    var openid = app.globalData.openid;
    var link = app.globalData.schlink;
    var limit=30;
    wx.request({
      url: getApp().globalData.baseUrl + 'integralrecord',
      data: {
        link: link,
        openid: openid,
        limit: limit
      },
      method: "get",
      header: {},
      success: function (res) {
        if (res.data.code==200){
          if (res.data.data.length > 0) {
            var resultdata = res.data.data;
            that.setData({ recorddata: resultdata });
          }
        }
        that.setData({loadingHidden:true });
      }
    })
  },
  onLoad: function (options) {
    var that = this;
    if (app.globalData.userInfo) {
      that.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else {
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          that.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
    if (!getApp().globalData.bindInfo){
      wx.redirectTo({
        url: '../binding/binding'
      })
    }
    if (!app.isbindBack) {
      app.isbindBack = function (result) {
        if (result.code == 1) {
          getApp().globalData.bindInfo = result.data;
        } else if (result.code == 0) {
          wx.redirectTo({
            url: '../binding/binding'
          })
        }
      }
    }

    this.getLocation();
  },
  onReady: function () {
  },
  onShow: function () {
  },
  onHide: function () {
  },
  onUnload: function () {
  },
  onPullDownRefresh: function () {
  },
  onReachBottom: function () {
  },
  onShareAppMessage: function () {
  },
    getUserInfo: function (e) {
    var that = this;
    if (e.detail.userInfo) {
      app.globalData.userInfo = e.detail.userInfo;
      that.setData({
        hasUserInfo: true,
        canIUse: false
      })
    }
  }
})